package com.java.base.lock;

public class SyncLock {

    static final Object object = new Object();

    public static void main(String[] args) {


        new Thread(() -> {
            synchronized (object) {
                System.out.println(Thread.currentThread().getName() + " object1");
            }
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();

        new Thread(() -> {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (object) {
                System.out.println(Thread.currentThread().getName() + " object2");
            }

        }).start();


    }


}
